<?php
require_once 'BaseMySQLDAO.php';

class GameLinkDAO extends BaseMySQLDAO {

    public function __construct($context) {
        parent::__construct($context, 'game_link');
    }

    public function getAllGameLink() {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "SELECT * FROM game_link";
            $param = array();
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameLinkByLimitTPG($start, $limit) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						ORDER BY game_link.id DESC
            			LIMIT :start, :limit 
            		 ";
            $param = array(":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameLinkByLimitMobile($start, $limit) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						ORDER BY game_link.id DESC
            			LIMIT :start, :limit 
            		 ";
            $param = array(":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameLinkByLimitNSGT($start, $limit) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						ORDER BY game_link.id DESC
            			LIMIT :start, :limit 
            		 ";
            $param = array(":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameLinkByLimitCGMB($start, $limit) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "	SELECT 
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						ORDER BY game_link.id DESC
            			LIMIT :start, :limit 
            		 ";
            $param = array(":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
        	print_r($exception);
        	exit();
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getAllGameLinkByLimitMMBG($start, $limit) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						ORDER BY game_link.id DESC
            			LIMIT :start, :limit 
            		 ";
            $param = array(":start" => $start, ":limit" => $limit);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }

    public function getGameLinkByGameId($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction();

            $inSQL = "SELECT * FROM game_link WHERE game_id = :game_id ";
            $param = array('game_id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function countGameLinkTPG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "  SELECT count(id) as total FROM game_link ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameLinkCGMB() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "  SELECT count(id) as total FROM game_link ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameLinkMobile() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "  SELECT count(id) as total FROM game_link ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameLinkNSGT() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "  SELECT count(id) as total FROM game_link ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function countGameLinkMMBG() {
        $result = null;
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "  SELECT count(id) as total FROM game_link ";
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result['total'];
    }
    
	public function getGameLinkByIDTPG($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "SELECT * FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL,$param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByIDCGMB($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "SELECT * FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL,$param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByIDMMBG($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "SELECT * FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL,$param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
  	public function getGameLinkByIDNSGT($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "SELECT * FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadOneRow($inSQL,$param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
    public function getGameLinkByGameCateIdTPG($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_category_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameCateIdMobile($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_category_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameCateIdCGMB($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
			
            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_category_id = :id 
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameCateIdNSGT($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_category_id = :id  
					";
            $param = array(':id' => $id);
            echo $inSQL."<br>";
            echo "<pre>";
            	print_r($param);
            echo "</pre>";
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameCateIdMMBG($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_category_id = :id 
					";
            $param = array(':id' => $id);
            
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameIdTPG($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameIdMobile($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameIdCGMB($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameIdMMBG($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function getGameLinkByGameIdNSGT($id) {
        $result = array();
        try {
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');

            $inSQL = "	SELECT
							game_link.type as type,
							game_link.file_type as file_type,
							game_link.id as id,
							game_link.game_id as game_id,
							game_link.device as device,device_id,
							game_link.link as link,
							game_link.game_category_id as game_category_id,
							game_category.`name` as category_name,
							game.`name` as game_name,
							IF (ISNULL(device.device_name),'0',device.device_name) as device_name
						FROM
							game_link
						LEFT JOIN game_category ON game_link.game_category_id = game_category.id 
						LEFT JOIN game ON game_link.game_id = game.id
						LEFT JOIN device ON game_link.device_id = device.id
						WHERE game_link.game_id = :id  
					";
            $param = array(':id' => $id);
            $result = $this -> getContext() -> getTransaction() -> getMySQLConnection() -> loadManyRow($inSQL, $param);

            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
        }
        return $result;
    }
    
	public function insertGameLink($param) {
        $result = null;
        try {
            $inSQL = "INSERT INTO
                        game_link(id, game_category_id, game_id, type, file_type, device, device_id, link)
                        VALUES (
                            :id, :game_category_id, :game_id, :type, :file_type, :device, :device_id, :link
                        )";
            $queryParam = array(
                                ':id' => NULL,
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function insertGameLinkMobile($param) {
        $result = null;
        try {
            $inSQL = "INSERT INTO
                        game_link(id, game_category_id, game_id, type, file_type, device, device_id, link)
                        VALUES (
                            :id, :game_category_id, :game_id, :type, :file_type, :device, :device_id, :link
                        )";
            $queryParam = array(
                                ':id' => NULL,
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function insertGameLinkMMBG($param) {
        $result = null;
        try {
            $inSQL = "INSERT INTO
                        game_link(id, game_category_id, game_id, type, file_type, device, device_id, link)
                        VALUES (
                            :id, :game_category_id, :game_id, :type, :file_type, :device, :device_id, :link
                        )";
            $queryParam = array(
                                ':id' => NULL,
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkTPG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    game_category_id = :game_category_id,
                                    game_id = :game_id,
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkCGMB($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    game_category_id = :game_category_id,
                                    game_id = :game_id,
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         
        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkMMBG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    game_category_id = :game_category_id,
                                    game_id = :game_id,
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkNSGT($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    game_category_id = :game_category_id,
                                    game_id = :game_id,
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
                                ':id' => $param['id'],
                                ':game_category_id' => $param['game_category_id'],
                                ':game_id' => $param['game_id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkAjaxTPG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => $param['id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkAjaxCGMB($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => $param['id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkAjaxMobile($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => $param['id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkAjaxMMBG($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => $param['id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function updateGameLinkAjaxNSGT($param) {
        $result = null;
        try {
            $inSQL = "UPDATE game_link SET
                                    type = :type,
                                    file_type = :file_type,
                                    device = :device,
                                    device_id = :device_id,
                                    link = :link
                        WHERE id = :id
                        ";
            $queryParam = array(
            					':id' => $param['id'],
                                ':type' => $param['type'],
                                ':file_type' => $param['file_type'],
                                ':device' => $param['device'],
                                ':device_id' => $param['device_id'],
            					':link' => $param['link']
                            );
            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $queryParam);
            $this -> getContext() -> getTransaction() -> closeTransaction();
         

        } catch (Exception $exception) {
            print_r($exception);
            exit;
        }
        return $result;
    }
    
	public function deleteGameLinkTPG($id) {
        try {

            $inSQL = "   DELETE FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('thanhphogame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameLinkNSGT($id) {
        try {

            $inSQL = "   DELETE FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('ngoisaogamethu');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameLinkCGMB($id) {
        try {

            $inSQL = "   DELETE FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('choigamemobi');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameLinkMobile($id) {
        try {

            $inSQL = "   DELETE FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('mobile');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
	public function deleteGameLinkMMBG($id) {
        try {

            $inSQL = "   DELETE FROM game_link WHERE id = :id ";
            $param = array(':id' => $id);

            $this -> getContext() -> getTransaction() -> startTransaction('mymobigame');
            $this -> getContext() -> getTransaction() -> getMySQLConnection() -> executeNonQuery($inSQL, $param);
            $this -> getContext() -> getTransaction() -> closeTransaction();
            
        } catch (Exception $exception) {
            $this -> getContext() -> logException($exception);
            return false;
        }
        return true;
    }
    
}
?>